package com.mystery.service.impl;

import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.mystery.mapper.UserMapper;
import com.mystery.pojo.User;
import com.mystery.service.UserService;

import java.util.List;


@Service
public class UserServiceImpl implements UserService {

    @Autowired
    UserMapper userMapper;

	public User login(String username, String password) {
		User user = null;
        if(!StringUtils.isEmpty(username) && !StringUtils.isEmpty(password)){
            user = userMapper.login(username,password);
        }
        return user;
	}

    @Override
    public int update(String username, String password) {
        return userMapper.update(username,password);
    }

    @Override
    public int addFitness(User user) {
        return userMapper.addFitness(user);
    }

    public int addUser(User user) {
		return userMapper.addUser(user);
		
	}

    @Override
    public User fitnessLogin(String username, String password) {
        User user = null;
        if(!StringUtils.isEmpty(username) && !StringUtils.isEmpty(password)){
            user = userMapper.fitnessLogin(username,password);
        }
        return user;
    }

    @Override
    public int delete(long id) {
        return userMapper.delete(id);
    }

    @Override
    public List<User> search(String username) {
        return userMapper.search(username);
    }

    @Override
    public List<User> list() {
        return userMapper.list();
    }

    @Override
    public User managerLogin(String username, String password) {
        User user = null;
        if(!StringUtils.isEmpty(username) && !StringUtils.isEmpty(password)){
            user = userMapper.managerLogin(username,password);
        }
        return user;
    }

}
